<?php
require_once('../libraryfiles/config.php');
$content = 'profile.php';
$include = ' 
	<script src="'.W_ROOT.'/js/jquery.js" type="text/javascript"></script>
 ';
$var = '<span style="color:#F00">*</span>';

require_once TMP_USER_PATH;
$error = isset($_GET['error'])?$_GET['error']:'';
$success = isset($_GET['success'])?$_GET['success']:'';
	// Requit
	$var = '<span style="color:#F00">*</span>';
?>
<script>
		
		$(document).ready(function() {	
			$(".a").attr("disabled", "disabled");
		})
		function edit(){
			$(".a").removeAttr("disabled");
			$('#btnEdit').replaceWith('<input type="submit" value="Update your Profile?" name="btnEdit" " class="btn btn-warning" />');
		}
</script>

<script>
	function sh_firstname()
	{
		var x=document.forms["frmCheckout"]["txtShippingFirstName"].value
		if (x==null || x=="")
		{
			document.getElementById("a1").innerHTML = "Please in put first name!";
		}else{
			document.getElementById("a1").innerHTML = "";
		}
	}
	function sh_lastname()
	{
		var x=document.forms["frmCheckout"]["txtShippingLastName"].value
		if (x==null || x=="")
		{
			document.getElementById("a2").innerHTML = "Please in put last name!";
		}else{
			document.getElementById("a2").innerHTML = "";
		}
	}
	
		function upass()
	{
		var x=document.forms["frmCheckout"]["user_pass"].value
		if (x==null || x=="")
		{
		 	document.getElementById("demo2").innerHTML = "Password must be filled out";
		}else{
			 document.getElementById("demo2").innerHTML = "";
		}
	}
	
	function sh_address()
	{
		var x=document.forms["frmCheckout"]["txtShippingAddress"].value
		if (x==null || x=="")
		{
			document.getElementById("a3").innerHTML = "Please in put address!";
		}else{
			document.getElementById("a3").innerHTML = "";
		}
	}
	function sh_phone()
	{
		var x=document.forms["frmCheckout"]["txtShippingPhone"].value
		if (x==null || x=="")
		{
			document.getElementById("a4").innerHTML = "Please in put phone number!";
		}else{
			document.getElementById("a4").innerHTML = "";
		}
	}
	function sh_mobile()
	{
		var x=document.forms["frmCheckout"]["txtShippingMobile"].value
		if (x==null || x=="")
		{
			document.getElementById("a5").innerHTML = "Please in put mobile number!";
		}else{
			document.getElementById("a5").innerHTML = "";
		}
	}
	function sh_email()
	{
		var x=document.forms["frmCheckout"]["txtShippingEmail"].value
		if (x==null || x=="")
		{
			document.getElementById("a6").innerHTML = "Please in put email!";
		}else{
			document.getElementById("a6").innerHTML = "";
		}
	}
	function sh_state()
	{
		var x=document.forms["frmCheckout"]["txtShippingState"].value
		if (x==null || x=="")
		{
			document.getElementById("a7").innerHTML = "Please in put province / state!";
		}else{
			document.getElementById("a7").innerHTML = "";
		}
	}
	function sh_city()
	{
		var x=document.forms["frmCheckout"]["txtShippingCity"].value
		if (x==null || x=="")
		{
			document.getElementById("a8").innerHTML = "Please in put city!";
		}else{
			document.getElementById("a8").innerHTML = "";
		}
	}
	function sh_country()
	{
		var x=document.forms["frmCheckout"]["txtShippingCountry"].value
		if (x==null || x=="")
		{
			document.getElementById("a9").innerHTML = "Please in put country!";
		}else{
			document.getElementById("a9").innerHTML = "";
		}
	}
	function sh_zip()
	{
		var x=document.forms["frmCheckout"]["txtShippingPostalCode"].value
		if (x==null || x=="")
		{
			document.getElementById("a10").innerHTML = "Please in put postal / zip Code!";
		}else{
			document.getElementById("a10").innerHTML = "";
		}
	}
	function pay_firstname()
	{
		var x=document.forms["frmCheckout"]["txtPaymentFirstName"].value
		if (x==null || x=="")
		{
			document.getElementById("b1").innerHTML = "Please in put first name!";
		}else{
			document.getElementById("b1").innerHTML = "";
		}
	}
	function pay_lastname()
	{
		var x=document.forms["frmCheckout"]["txtPaymentLastName"].value
		if (x==null || x=="")
		{
			document.getElementById("b2").innerHTML = "Please in put last name!";
		}else{
			document.getElementById("b2").innerHTML = "";
		}
	}
	function pay_address()
	{
		var x=document.forms["frmCheckout"]["txtPaymentAddress"].value
		if (x==null || x=="")
		{
			document.getElementById("b3").innerHTML = "Please in put address!";
		}else{
			document.getElementById("b3").innerHTML = "";
		}
	}
	function pay_phone()
	{
		var x=document.forms["frmCheckout"]["txtPaymentPhone"].value
		if (x==null || x=="")
		{
			document.getElementById("b4").innerHTML = "Please in put phone number!";
		}else{
			document.getElementById("b4").innerHTML = "";
		}
	}
	function pay_mobile()
	{
		var x=document.forms["frmCheckout"]["txtPaymentMobile"].value
		if (x==null || x=="")
		{
			document.getElementById("b5").innerHTML = "Please in put mobile number!";
		}else{
			document.getElementById("b5").innerHTML = "";
		}
	}
	function pay_email()
	{
		var x=document.forms["frmCheckout"]["txtPaymentEmail"].value
		if (x==null || x=="")
		{
			document.getElementById("b6").innerHTML = "Please in put email!";
		}else{
			document.getElementById("b6").innerHTML = "";
		}
	}
	function pay_state()
	{
		var x=document.forms["frmCheckout"]["txtPaymentState"].value
		if (x==null || x=="")
		{
			document.getElementById("b7").innerHTML = "Please in put province / state!";
		}else{
			document.getElementById("b7").innerHTML = "";
		}
	}
	function pay_city()
	{
		var x=document.forms["frmCheckout"]["txtPaymentCity"].value
		if (x==null || x=="")
		{
			document.getElementById("b8").innerHTML = "Please in put city!";
		}else{
			document.getElementById("b8").innerHTML = "";
		}
	}
	function pay_country()
	{
		var x=document.forms["frmCheckout"]["txtPaymentCountry"].value
		if (x==null || x=="")
		{
			document.getElementById("b9").innerHTML = "Please in put country!";
		}else{
			document.getElementById("b9").innerHTML = "";
		}
	}
	function pay_zip()
	{
		var x=document.forms["frmCheckout"]["txtPaymentPostalCode"].value
		if (x==null || x=="")
		{
			document.getElementById("b10").innerHTML = "Please in put postal / zip Code!";
		}else{
			document.getElementById("b10").innerHTML = "";
		}
	}
</script>
<script language="JavaScript" type="text/javascript" src="<?php echo W_ROOT;?>/js/checkout.js"></script>
	<div class="box">
<div class="title">Profile</div>
<!-- Width 568px-->
<?php
if($error!="")
{
?>
<div align="center"><strong style="color:#F00;"><?php echo $error;?></strong></div>
<?php
}
else if($success!=""){
?>	
	<div align="center"><strong style="color:#F00;"><?php echo $success;?></strong></div>
      <?php 
}
//edit
	$editRow="SELECT * FROM tbluser INNER JOIN tblcountries ON tbluser.id=tblcountries.id INNER JOIN tbluser_profile ON tbluser_profile.provider=tbluser.id where tbluser.id=".$_SESSION['acc_id'];
	$query=mysql_query($editRow);
	
	$result=mysql_fetch_array($query);
	//print_r($result);die();
?>
 
   
    <!-- Starting form buyer Register -->
    <form name="registerForm" id="frmCheckout" action="<?php echo W_ROOT; ?>/process_register.php?action=edit_b" method="post">
<table class="table table-hover">
    	<tr>
            <td colspan="2">
               <div style="float:left; width:35%;"><span style="color:#417EFB; font-size:18px;">Profile Information</span></div>
               <div style="float:right;"><span class="coloRed">Note : All (*) are important!</span></div>
            </td>
       	</tr>
    	<tr>
        	<td><label for="txtShippingFirstName">First Name <?php echo $var; ?> : </label></td>
            <td><div id="a1" class="coloRed"></div><input class="span12 no-boder" type="text" name="first_name" id="txtShippingFirstName" value="<?php echo $result['first_name']; ?>" onblur="sh_firstname()" onclick="edit();"/></td>
        </tr>        
        <tr>
        	<td><label for="txtShippingLastName">Last Name <?php echo $var; ?> : </label></td>
            <td><div id="a2" class="coloRed"></div><input class="span12 no-boder" type="text" name="last_name" id="txtShippingLastName" value="<?php echo $result['last_name']; ?>" onblur="sh_lastname()" onclick="edit();"/></td>
        </tr>
        <tr>
        	<td><label for="user_pass" style="width:100px;">Password <?php echo $var; ?> : </label></td>
            <td><div id="demo2" class="coloRed"></div><input value="<?php echo $result['user_pass']; ?>" class="span12 no-boder" type="password" name="user_pass" id="user_pass" onblur="upass();" onclick="edit();" /></td>
        </tr>           
        <tr>
        	<td><label for="selShippingTitle">Title <?php echo $var; ?> : </label></td>
            <td>: <select id="selShippingTitle" name="title" onclick="edit();">
                	<option selected="selected">Please select one</option>                   
                    <option <?php echo($result['title']=="Mr.")?' selected="selected"':''?>>Mr.</option>
                    <option <?php echo($result['title']=="Mrs.")?' selected="selected"':''?>>Mrs.</option>
                    <option <?php echo($result['title']=="Miss.")?' selected="selected"':''?>>Miss.</option>
                </select>
            </td>
        </tr>
        <tr>
        	<td><label for="txtShippingAddress">Address <?php echo $var;?> : </label></td>
            <td><div id="a3" class="coloRed"></div><input class="span12 no-boder" type="text" name="address" id="txtShippingAddress" value="<?php echo $result['address']; ?>" onblur="sh_address()" onclick="edit();"/></td>
        </tr>        
        <tr>
        	<td><label for="txtShippingPhone">Telephone <?php echo $var;?> : </label></td>
            <td><div id="a4" class="coloRed"></div><input class="span12 no-boder" type="text" name="phone" id="txtShippingPhone" value="<?php echo $result['phone']; ?>" onblur="sh_phone()" onclick="edit();"/></td>
        </tr>        
        <tr>
        	<td><label for="txtShippingMobile">Mobile Phone <?php echo $var;?> : </label></td>
            <td><div id="a5" class="coloRed"></div><input class="span12 no-boder" type="text" name="mobile" id="txtShippingMobile" value="<?php echo $result['mobile']; ?>" onblur="sh_mobile()" onclick="edit();"/></td>
        </tr>        
        <tr>
        	<td><label for="txtShippingEmail">Email <?php echo $var;?> : </label></td>
            <td><div id="a6" class="coloRed"></div><input class="span12 no-boder" type="text" name="email" id="txtShippingEmail" value="<?php echo $result['email']; ?>" onblur="sh_email()" onclick="edit();"/></td>
        </tr>
        
        <tr>
        	<td><label for="txtShippingState">Province / State <?php echo $var; ?> : </label></td>
            <td><div id="a7" class="coloRed"></div><input class="span12 no-boder" type="text" name="region" id="txtShippingState" value="<?php echo $result['region']; ?>" onblur="sh_state()" onclick="edit();"/></td>
        </tr>
        
        <tr>
        	<td><label for="txtShippingCity">City <?php echo $var; ?> : </label></td>
            <td><div id="a8" class="coloRed"></div><input class="span12 no-boder" type="text" name="city" id="txtShippingCity" onblur="sh_city()" value="<?php echo $result['city']; ?>" onclick="edit();"/></td>
        </tr>
        
        <tr>
        	<td><label for="txtShippingCountry">Country <?php echo $var;?> : </label></td>
            <td><div id="a9" class="coloRed"></div>
            <?php
				$str = "SELECT id, country_name from tblcountries order by country_name";
				$query = mysql_query($str);
				$num_rows = mysql_num_rows($query);
				
			?>
            <select name="country_id" id="txtShippingCountry" class="span12 no-boder" onblur="sh_country()" onclick="edit();">
                    <?php while($data = mysql_fetch_array($query)){ ?>
                    <option value="<?php echo $data['id'];?>" <?php echo($data['id']==$result['country_id'])?' selected="selected"':''?>><?php echo $data['country_name']; ?></option>
                    <?php } ?>
                </select>                
             </td>
        </tr>       
        <tr>
        	<td><label for="txtShippingPostalCode">Postal / Zip Code <?php echo $var;?> : </label></td>
            <td><div id="a10" class="coloRed"></div><input class="span12 no-boder" type="text" name="zip" id="txtShippingPostalCode" onblur="sh_zip()" value="<?php echo $result['zip']; ?>" onclick="edit();"/></td>
        </tr>       
    </table> 
    <input type="button" value="Edit" id="btnEdit" name="btnEdit" onclick="edit();" class="btn"/>
    </form> 
	</div><!--<div class="box">-->
